package com.ruoyi.novel.controller;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.novel.domain.NovelDTO;
import com.ruoyi.novel.service.HomePageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.xml.stream.events.StartDocument;
import java.util.List;

/**
 * 小说首页
 * @author fst
 */
@RestController
@RequestMapping("/novel")
public class HomePageController  extends BaseController {
    @Autowired
    private HomePageService homePageService;
    /**
     * 根据点击量对小说排行
     * @author fst
     */

    @GetMapping("/ListByClick")
    public TableDataInfo ListByClick(){
        List<NovelDTO> novelDTOS = homePageService.ListByClick();
        return getDataTable(novelDTOS);
    }
    /**
     * 根据月票对小说排行
     * @author fst
     */

    @GetMapping("/ListByPass")
    public TableDataInfo ListByPass(){
        List<NovelDTO> novelDTOS = homePageService.ListByPass();
        return getDataTable(novelDTOS);
    }
    /**
     * 根据收藏量对小说排行
     *  @author fst
     */

    @GetMapping("/ListByCollection")
    public TableDataInfo ListByCollection(){
        List<NovelDTO> novelDTOS = homePageService.ListByCollection();
        return getDataTable(novelDTOS);
    }
    /**
     * 本月新书榜（本月根据收藏排序）
     * @author fst
     */

    @GetMapping("/ListByMonth")
    public TableDataInfo ListByMonth(){
        List<NovelDTO> novelDTOS = homePageService.ListByMonth();
        return getDataTable(novelDTOS);
    }
    /**TODO 智能推荐
     * 根据用户id查询书架的小说，根据小说的类型推荐相似的小说
     * */
    @GetMapping("/ListByIntelligent")
    public TableDataInfo ListByIntelligent(@RequestParam Long userId){
        List<NovelDTO> novelDTOS = homePageService.ListByIntelligent(userId);
        return getDataTable(novelDTOS);
    }
}
